package com.heima.leetcode.datastructure.heap;

/**
 * 用堆实现数组元素的排序，时间复杂度为O(nlog(n))
 * @author 勾新杰
 * @version 1.0
 * @date 2024/9/6 15:52
 */
public class ArraySort {
    public static void orderArrayByHeapAsc(int[] arr){
        MaxHeap heap = new MaxHeap(arr);
        for (int i = arr.length - 1; i >= 0; i--) {
            heap.poll();
        }
    }

    public static void orderArrayByHeapDesc(int[] arr){
        MinHeap heap = new MinHeap(arr);
        for (int i = arr.length - 1; i >= 0; i--){
            heap.poll();
        }
    }
}
